<?php
//模型
class companyModel extends MY_Model {
	function __construct(){
		parent::__construct();
		$this->table = 'company';
	}
	
	function get_list($arr,$page=1,$size=10){
		$where = ' 1 ';
		
		
		$res = $this->_where_get_list($where,$page,$size,"ORDER BY sort ASC,id DESC");
		return $res;
	}
	
	function get_info($id){
		$sql  = "select * from ".$this->db->dbprefix.$this->table." where id='{$id}' limit 1";
		$query = $this->db->query($sql);
		$row = $query->row_array();
		return $row;
	}
	
	function ids_get($ids){
		if(is_array($ids)){
			$ids = implode(',',$ids);
		}
		if(empty($ids)){
			return false;
		}
		
		$sql  = "select id,sx_name as name from ".$this->db->dbprefix.$this->table." where id in({$ids})";
		$query = $this->db->query($sql);
		$res = $query->result_array();
		return $res;
	}
	
	function ids_get_data($ids){
		if(!is_array($ids)){
			$ids = explode(',',$ids);
		}
		$arr = array();
		foreach($ids as $val){
			if(!empty($val)){
				$arr[] = $val;
			}
		}
		$ids = implode(',',$arr);
		
		if(empty($ids)){
			return false;
		}
		
		$sql  = "select id,name,sx_name from ".$this->db->dbprefix.$this->table." where id in({$ids})";
		$query = $this->db->query($sql);
		$res = $query->result_array();
		return $res;
	}
	
	function name_get_data($name){
		if(empty($name)){
			return false;
		}
		$sql  = "select * from ".$this->db->dbprefix.$this->table." where name='{$name}' OR sx_name='{$name}' limit 1";
		
		$query = $this->db->query($sql);
		$row = $query->row_array();
		return $row;
	}
}

